<#import "root://activities/common/kotlin_macros.ftl" as kt>
apply plugin: 'com.android.application'
apply from: '../signature/signature.gradle'
<@kt.addKotlinPlugins />

//指定APP DeepLink Scheme & Host
def deepLink = [:]
deepLink.scheme = "jpxx"
deepLink.host = "mobile"

android {
    compileSdkVersion rootProject.ext.build_versions.compile_version
    <#if compareVersionsIgnoringQualifiers(gradlePluginVersion, '3.0.0') lt 0>buildToolsVersion rootProject.ext.build_versions.build_tools</#if>

    defaultConfig {
        applicationId "${packageName}"
        //到versions.gradle修改相应信息
        minSdkVersion rootProject.ext.build_versions.min_sdk
        targetSdkVersion rootProject.ext.build_versions.target_sdk
        versionCode 1
        versionName "1.0"
        
        manifestPlaceholders = [
                appLabel       : "MVPDemo",
                DEEPLINK_SCHEME: deepLink.scheme,
                DEEPLINK_HOST  : deepLink.host
        ]

        buildConfigField "boolean", "DEV_MODE", "false"
        buildConfigField "String", "DATA_PATH", '"AppDir"' //app 数据保存目录

        //使用项目正式域名替换
        buildConfigField "String", "API_BASE_URL", '"https://xxx"'

        //app deepLink scheme and host

        ndk {
            abiFilters "armeabi-v7a"
        }

        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath true
                arguments = [
                        eventBusIndex       : 'com.eventbus.index.MyEventBusIndex',
                        AROUTER_MODULE_NAME : project.getName(),
                        AROUTER_GENERATE_DOC: "enable"
                ]
            }
        }

        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

    sourceSets {
        main {
            // 指定so库地址
            jniLibs.srcDirs = ['jniLibs']
        }
    }

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug_key

            buildConfigField "boolean", "DEV_MODE", "true"
            minifyEnabled false
        }

        release {
            signingConfig signingConfigs.release_key

            minifyEnabled true
            shrinkResources true
            zipAlignEnabled true
        }
    }

    flavorDimensions "YourDimensions"
    productFlavors {
        //测试环境
        DEV {
            dimension "YourDimensions"

            //实现一台设备同时安装Production和Staging环境APP
            applicationId "${packageName}.dev"

            manifestPlaceholders = [
                    appLabel: "MVPDemoSTG"
            ]

            ndk {
                abiFilters "armeabi-v7a", "x86"
            }

            //  使用项目测试域名替换
            buildConfigField "String", "API_BASE_URL", '"http://ztcapi.jpsycn.com/api/"'
        }
        //线上环境
        PROD {
            dimension "YourDimensions"
        }
    }

    //定义各渠道的channel name
    productFlavors.all { flavor ->
        flavor.manifestPlaceholders.put("CHANNEL_VALUE", name)
    }

    lintOptions {
        abortOnError false
    }
}

// 可导入aar包
repositories {
    flatDir() {
        dirs 'libs'
    }
}

dependencies {
    ${getConfigurationName("compile")} fileTree(dir: 'libs', include: ['*.jar'])
    ${getConfigurationName("compile")} rootProject.ext.deps.fastLib.common_base

    //${getConfigurationName("compile")} rootProject.ext.deps.fastLib.bridge_webview
    //${getConfigurationName("compile")} rootProject.ext.deps.fastLib.activity_swipe
    
    //Arouter
    annotationProcessor rootProject.ext.deps.aRouter.compiler
    //butterKnife
    annotationProcessor rootProject.ext.deps.butterknife.compiler
    //glide
    annotationProcessor rootProject.ext.deps.glide.compiler
    //dagger2
    annotationProcessor rootProject.ext.deps.dagger2.compiler

    //全局异常拦截
    implementation rootProject.ext.deps.errorCrash
    //event bus 如果项目不需要EventBus,就注视掉改行，并修改BaseActivity, BaseFragment
    implementation rootProject.ext.deps.eventBus.runtime
    annotationProcessor rootProject.ext.deps.eventBus.compiler

    // loading retry
    implementation rootProject.ext.deps.fastLib.loading_retry
    //封装的RecyclerView
    implementation rootProject.ext.deps.fastLib.smart_rv_adapter
    //bottom bar
    implementation rootProject.ext.deps.fastLib.bottombar
    //http log
    implementation (rootProject.ext.deps.chuck) {
        exclude group: 'com.android.support'
    }

    testImplementation 'junit:junit:4.12'
    
    <@kt.addKotlinDependencies />
}
